const path = require('path')
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const TransferWebpackPlugin = require("transfer-webpack-plugin");
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')

module.exports = merge(common, { // 将webpack.common.js合并到当前文件
  mode: 'production',
  devtool: 'none',  // 'source-map'会生成对于调试的完整的.map文件，但同时也会减慢打包速度
  output: {
    // filename: 'js/[name].js?[hash:5]',
    // publicPath: "../" // 打包输出的目录名，只包括html里在资源，包括html里的css、js、图片
  },
  plugins: [
    new OptimizeCSSAssetsPlugin (),
    new TransferWebpackPlugin([
      {
        from: `js/static`,
        to: `js`
      },
      {
        from: `js/main`,
        to: `map/js`
      },
      {
        from: `js/static`,
        to: `map/js`
      },
      {
        from: `css`,
        to: `map/css`
      }
    ], path.resolve(__dirname, "src"))
  ],

});


